package com.lanxiao.cloud.modules.file.application;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lanxiao.cloud.common.core.enums.StateEnum;
import com.lanxiao.cloud.common.web.service.ILog;
import com.lanxiao.cloud.modules.file.application.assembler.FileConfigureAssembler;
import com.lanxiao.cloud.modules.file.application.dto.FileConfigureDto;
import com.lanxiao.cloud.modules.file.domain.model.FileConfigure;
import com.lanxiao.cloud.modules.file.infrastructure.repository.FileConfigureMapper;
import java.util.List;
import org.springframework.stereotype.Component;

/**
 *
 * @author ：qiaoliang
 * @date ：2021-10-25
 */
@Component
public class FileConfigureQueryManager implements ILog<FileConfigure, Long>{

  private final FileConfigureAssembler fileConfigureAssembler;
  private final FileConfigureMapper fileConfigureMapper;

  public FileConfigureQueryManager(
      FileConfigureAssembler fileConfigureAssembler,
      FileConfigureMapper fileConfigureMapper) {
    this.fileConfigureAssembler = fileConfigureAssembler;
    this.fileConfigureMapper = fileConfigureMapper;
  }

  public List<FileConfigureDto> all() {
    return fileConfigureAssembler.toFileConfigureDto(fileConfigureMapper.selectList(
        new LambdaQueryWrapper<FileConfigure>().eq(FileConfigure::getState, StateEnum.NORMAL)));
  }

  @Override
  public FileConfigure selectById(Long id) {
    return fileConfigureMapper.selectById(id);
  }

}
